﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;

namespace Mimoza.DateTimePlugin
{
    public class DateTimePluginData
    {
        string m_TimeZoneId = null;
        string m_timeZoneStandartName = null;
        int m_baseUtcOffsetSec;

        string m_timeZoneDelightName = null;
        bool m_supportsDaylightSavingTime;
        int m_daylightDeltaSec;

        bool m_isTimeSynchronize = false;

        byte[] m_registryData = null;

        public string TimeZoneId
        {
            get { return m_TimeZoneId; }
            set { m_TimeZoneId = value; }
        }
        public string TimeZoneStandartName
        {
            get { return m_timeZoneStandartName; }
            set { m_timeZoneStandartName = value; }
        }

        public int BaseUtcOffsetSec 
        {
            get { return m_baseUtcOffsetSec; }
            set { m_baseUtcOffsetSec = value; }
        }

        public string TimeZoneDelightName
        {
            get { return m_timeZoneDelightName; }
            set { m_timeZoneDelightName = value; }
        }

        public bool SupportsDaylightSavingTime
        {
            get { return m_supportsDaylightSavingTime; }
            set { m_supportsDaylightSavingTime = value; }
        }

        public int DaylightDeltaSec
        {
            get { return m_daylightDeltaSec; }
            set { m_daylightDeltaSec = value; }
        }

        public bool IsTimeSynchronize
        {
            get { return m_isTimeSynchronize; }
            set { m_isTimeSynchronize = value; }
        }

        public byte[] RegistryData
        {
            get { return m_registryData; }
            set { m_registryData = value; }
        }

        public string Serialize()
        {
            XmlSerializer serializer = new XmlSerializer(typeof(DateTimePluginData));
            TextWriter text = new StringWriter();
            serializer.Serialize(text, this);
            return text.ToString();
        }

        public static DateTimePluginData Deserialize(string data)
        {
            XmlSerializer deserializer = new XmlSerializer(typeof(DateTimePluginData));
            using (TextReader text = new StringReader(data))
            {
                return deserializer.Deserialize(text) as DateTimePluginData;
            }
        }
    }
}
